import { useEffect } from 'react'
import { useHistory, useParams } from 'umi'
import { setCookie } from '@/storage'
import { getData } from '@/servers/http'
import { api } from '@/servers/api'

const Resume = (props: any) => {
    const history = useHistory()
    const { id } = useParams<any>()

    /** 获取关卡详情 */
    const getDetails = () => {
        getData(`${api.userBarriersById}${id}`).then(res => {
            if (res?.status !== 200) return
            history.push(`/level?id=${res?.data?.scene_id}`)
        })
    }

    useEffect(() => {
        const { token } = props.location.query
        console.log('回来啦！', props)
        console.log('回来啦！', token)
        setCookie('PLATFORMTOKEN', token)
        if (id) {
            getDetails()
        }
    }, [props, history])

    return <div />
}

export default Resume
